<template>
  <div>
    <com-header></com-header>
    <nav-bread>
      <span>OrderSuccess</span>
    </nav-bread>
    <div class="container">
      <div class="page-title-normal">
        <h2 class="page-title-h2"><span>check out</span></h2>
      </div>
      <!-- 进度条 -->
      <div class="check-step">
        <ul>
          <li class="cur"><span>Confirm</span> address</li>
          <li class="cur"><span>View your</span> order</li>
          <li class="cur"><span>Make</span> payment</li>
          <li class="cur"><span>Order</span> confirmation</li>
        </ul>
      </div>

      <div class="order-create">
        <div class="order-create-pic"><img src="../../static/ok-2.png" alt=""></div>
        <div class="order-create-main">
          <h3>Congratulations! <br>Your order is under processing!</h3>
          <p>
            <span>Order ID：{{orderId}}</span>
            <span>Order total：{{orderTotal | currency('$')}}</span>
          </p>
          <div class="order-create-btn-wrap">
            <div class="btn-l-wrap">
              <router-link class="btn btn--m" to="/cart">Cart List</router-link>
            </div>
            <div class="btn-r-wrap">
              <router-link class="btn btn--m" to="/">Goods List</router-link>
            </div>
          </div>
        </div>
      </div>
    </div>
    <com-footer></com-footer>
  </div>
</template>

<script>
  import '../assets/css/base.css'
  import '../assets/css/checkout.css'
  import ComHeader from '../components/ComHeader'
  import ComFooter from '../components/ComFooter'
  import NavBread from '../components/NavBread'
  import axios from 'axios'

  export default {
    name: 'orderSuccess',
    components: {
      ComHeader,
      ComFooter,
      NavBread
    },
    data () {
      return {
        orderId: '',
        orderTotal: 0
      }
    },
    methods: {
      getOrderTotal() {
        axios.post('/user/getOrderTotal', {orderId: this.$route.query.orderId}).then((res) => {
          if (res.data.status == 0) {
            this.orderId = res.data.result.orderId
            this.orderTotal = res.data.result.orderTotal
            this.$store.dispatch('getCartCount')
          }
        })
      }
    },
    mounted() {
      if (!this.$store.state.nickName) this.$router.push('/')
      this.getOrderTotal()
    }
  }
</script>
